//
//  A_1ViewController.m
//  RACExamale
//
//  Created by cym_bj on 2017/11/29.
//  Copyright © 2017年 com.cym. All rights reserved.
//

#import "A_1ViewController.h"
#import <ReactiveObjC/ReactiveObjC.h>
@interface A_1ViewController ()

@end

@implementation A_1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title=@"RAC初体验、RACSignal";

    /*
     
      RACSignal
     使用步骤: 1、创建信号  2：订阅信号  3、发送信号
     
     
     */
    
    // 1、创建信号 (泠信号)
    
    RACSignal *signal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        
        //3、发送信号
        NSLog(@"信号被订阅就会被调用");
        [subscriber sendNext:@"发送信号"];
        
        return nil;
    }];
    
    
    //2、订阅信号 （热信号）
    [signal subscribeNext:^(id  _Nullable x) {
       
        // x:信号发送的内容  只要订阅者发送数据就会调用 
        NSLog(@"%@",x);
    }];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
